//package com.yunxi.rocketMq.producer;
//
//import com.yunxi.rocketMq.config.RocketConfig;
//import org.apache.rocketmq.client.exception.MQClientException;
//import org.apache.rocketmq.client.producer.DefaultMQProducer;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.ApplicationListener;
//import org.springframework.context.event.ContextRefreshedEvent;
//import org.springframework.stereotype.Component;
//
//@Component
//public class OtdPlanProducer implements ApplicationListener<ContextRefreshedEvent> {
//
//  /*  private DefaultMQProducer producer;
//    @Autowired
//    RocketConfig rocketConfig;
//
//    @Override
//    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
//        String otdPlanProducerGroup = rocketConfig.getOtdPlanProducerGroup();
//        producer = new DefaultMQProducer(otdPlanProducerGroup);
//
//        //指定NameServer地址，多个地址以 ; 隔开
//        //如 producer.setNamesrvAddr("192.168.100.141:9876;192.168.100.142:9876;192.168.100.149:9876");
//        producer.setNamesrvAddr(rocketConfig.getNameService());
//        producer.setMaxMessageSize(4194304);
//       // producer.setCreateTopicKey("TOPIC_LOG");
//        start();
//    }
//    public DefaultMQProducer getProducer(){
//        return this.producer;
//    }
//
//    *//**
//     * 对象在使用之前必须要调用一次，只能初始化一次
//     *//*
//    public void start(){
//        try {
//            this.producer.start();
//        } catch (MQClientException e) {
//            e.printStackTrace();
//        }
//    }
//
//
//    *//**
//     * 一般在应用上下文，使用上下文监听器，进行关闭
//     *//*
//    public void shutdown(){
//        this.producer.shutdown();
//    }*/
//
//}
